package com.superlistaportable.sales;

import java.util.List;

import twitter4j.Status;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.superlistaportable.R;

public class SalesAdapter extends BaseAdapter{

	private Context _context;
	private SalesModel _model;
	private List<Status> sales = null;
	private LayoutInflater inflater=null;
	
	public SalesAdapter(Context context, SalesModel model, List<Status> statuses){
		this._context = context;
		this._model = model;
		this.sales = statuses;
		inflater = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public int getCount() {
		return sales.size();
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null){
			convertView=inflater.inflate(R.layout.sales_list_item, null);
		}
		
        TextView sale = (TextView)convertView.findViewById(R.id.textSales);
        sale.setText(sales.get(position).getText());
		
		return convertView;
	}
	
}
